extends Control

# UI 界面
# 1. 系统声音声效的控制
# 2. 鼠标点击音效
# 3. 按钮的控制与响应
# 4. 背景的滚动

@onready var background = $DayBackground
@onready var click_sound = $ClickSound

@onready var bgm_button = $HBoxContainer/OptionMenu/BGMButton
@onready var sfx_button = $HBoxContainer/OptionMenu/SFXButton


func _ready():
	set_bgm_text()
	set_sfx_text()
	
func _process(delta):
	background.scroll_offset.x += 50.0*delta

func set_bgm_text():
	if Global.bgm_enable:
		bgm_button.set_text("音乐：关")
	else:
		bgm_button.set_text("音乐：开")
		
func set_sfx_text():
	if Global.sfx_enable:
		sfx_button.set_text("音效：关")
	else:
		sfx_button.set_text("音效：开")
	
func _on_bgm_button_pressed():
	Global.toggle_bgm()
	set_bgm_text()

func _on_sfx_button_pressed():
	Global.toggle_sfx()
	set_sfx_text()
	
func _on_start_pressed():
	Global.start_game()

func _on_quit_pressed():
	get_tree().quit()
